package com.hctrl.mybatis.interceptor;

import org.mybatis.spring.boot.autoconfigure.ConfigurationCustomizer;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author hanchao
 * @version 1.0
 * @date 2022/5/27 20:20
 */
@Configuration
@ConditionalOnProperty(prefix = "spring.profiles",name = "active",havingValue = "dev")
public class MyBatisConfig {

    @Bean
    public ConfigurationCustomizer mybatisConfigurationCustomizer() {
        return new ConfigurationCustomizer() {
            @Override
            public void customize(org.apache.ibatis.session.Configuration configuration) {
                SqlPrintInterceptor sqlPrintInterceptor = new SqlPrintInterceptor();
                configuration.addInterceptor(sqlPrintInterceptor);
            }
        };
    }

}
